package com.moyq5.mvc.maker.test.bean.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import com.moyq5.mvc.maker.test.bean.custom.OwnerEntity;
import com.moyq5.mvc.maker.test.bean.enums.MerchAccountStatus;

/**
 * 商户结算账户变更
 * @author Moyq5
 * @date 2017年12月15日
 */
@Entity
@Table(name = "uc_account_change")
@DynamicUpdate
public class AccountChange extends OwnerEntity implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	/**
	 * 变更ID(主键)
	 */
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")@GenericGenerator(name = "native", strategy = "native")
    @Column(name = "change_id")
	private Long changeId;
	/**
	 * 原账户信息
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ori_account_id")
	private BankAccount oriAccount;
	/**
	 * 新账户信息
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "new_account_id", nullable = false)
	private BankAccount newAccount;
	/**
	 * 用户身份信息审核状态
	 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "user_status", columnDefinition="int(1) default '0'")
	private MerchAccountStatus userStatus;
	/**
	 * 银行账户信息审核状态
	 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "bank_status", columnDefinition="int(1) default '0'")
	private MerchAccountStatus bankStatus;
    /**
	 * 身份信息审核说明
	 */
	@Column(name = "user_remark", length = 300)
	private String userRemark;
	/**
	 * 银行账户审核说明
	 */
	@Column(name = "bank_remark", length = 300)
	private String bankRemark;
	/**
	 * 审核时间
	 */
	@Column(name = "mod_time", columnDefinition="datetime")
	private Date modTime;
	/**
	 * 添加时间（申请时间）
	 */
	@Column(name = "add_time", nullable = false, columnDefinition="datetime")
	private Date addTime;
	
	@PrePersist
	public void prePersist() {
		if (null == addTime) {
			addTime = new Date();
		}
		if (null == modTime) {
			modTime = new Date();
		}
		
	}
	@PreUpdate
	public void preUpdate() {
		if (null == modTime) {
			modTime = new Date();
		}
	}
	public Long getChangeId() {
		return changeId;
	}
	public void setChangeId(Long changeId) {
		this.changeId = changeId;
	}
	public BankAccount getOriAccount() {
		return oriAccount;
	}
	public void setOriAccount(BankAccount oriAccount) {
		this.oriAccount = oriAccount;
	}
	public BankAccount getNewAccount() {
		return newAccount;
	}
	public void setNewAccount(BankAccount newAccount) {
		this.newAccount = newAccount;
	}
	public MerchAccountStatus getBankStatus() {
		return bankStatus;
	}
	public void setBankStatus(MerchAccountStatus bankStatus) {
		this.bankStatus = bankStatus;
	}
	public Date getModTime() {
		return modTime;
	}
	public void setModTime(Date modTime) {
		this.modTime = modTime;
	}
	public Date getAddTime() {
		return addTime;
	}
	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
	public MerchAccountStatus getUserStatus() {
		return userStatus;
	}
	public void setUserStatus(MerchAccountStatus userStatus) {
		this.userStatus = userStatus;
	}
	public String getUserRemark() {
		return userRemark;
	}
	public void setUserRemark(String userRemark) {
		this.userRemark = userRemark;
	}
	public String getBankRemark() {
		return bankRemark;
	}
	public void setBankRemark(String bankRemark) {
		this.bankRemark = bankRemark;
	}
}
